package customerEnter.Frame.JDBCDao.SqlProcessing.mySql;

import org.apache.commons.lang.StringUtils;

import customerEnter.Frame.DaoDataTransmission.DaoFrameDMLBaseTransmission;
import customerEnter.Frame.DaoDataTransmission.DaoFramePameTransmission;
import customerEnter.Frame.DaoDataTransmission.PagingParametersResult;
import customerEnter.Frame.JDBCDao.Interface.DaoFrameSqlProcessingInterface;
import customerEnter.Frame.JDBCDao.daoFrame.SqlDataBaseController;
import customerEnter.Frame.JDBCDao.util.DaoFrameConntroller;

/**
 * 类描述：處理 添加的語句
 * 
 * 类名称：DaoFrameSqlProcessingInsertImpl
 * 
 * 创建人：dy
 * 
 * 创建时间：2017-7-12 下午3:50:39
 * 
 */
public class DaoFrameMySqlProcessingSelectPageImpl implements DaoFrameSqlProcessingInterface<String> {

	@SuppressWarnings("rawtypes")
	@Override
	public <T, K> String SqlProcessing(DaoFrameDMLBaseTransmission daoFrameDMLBaseTransmission,
			DaoFramePameTransmission<T, K> daoFramePameTransmission) {
		String where = daoFrameDMLBaseTransmission.getWhere();
		String order = daoFrameDMLBaseTransmission.getOrder();
		String descOrAsc = daoFrameDMLBaseTransmission.getDescOrAsc();
		int page = daoFrameDMLBaseTransmission.getPage();
		int size = daoFrameDMLBaseTransmission.getSize();
		if (StringUtils.isNotBlank(where) && where.contains("where 1=1")) {
			where = "";
		}
		daoFrameDMLBaseTransmission.setWhere("" + SqlDataBaseController.getWhere() + "  " + where + " order by " + order
				+ "  " + descOrAsc + " limit " + (page * size) + "," + size + " ");
		DaoFrameConntroller.ManageDaoFramePameTransmission(daoFrameDMLBaseTransmission, daoFramePameTransmission);
		daoFramePameTransmission.setPagingParametersResult(new PagingParametersResult());
		return daoFramePameTransmission.SQL;
	}

}
